//
//  LagreCollectionView.m
//  项目一TimeMovie
//
//  Created by apple on 16/4/5.
//  Copyright © 2016年 huangmingyu. All rights reserved.
//

#import "LagreCollectionView.h"
#import "LargeCell.h"

#define kCellID @"LargeCellID"

@implementation LagreCollectionView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout {
    
    if (self = [super initWithFrame:frame collectionViewLayout:layout]) {
        
        self.itemWidth = kScreenWidth - 100;
        //注册单元格
        [self registerNib:[UINib nibWithNibName:@"LargeCell" bundle:nil] forCellWithReuseIdentifier:kCellID];
        
        [self addObserver:self forKeyPath:@"self.currentIndex" options:NSKeyValueObservingOptionNew context:nil];
        
    }
    return self;
}


- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    
    LargeCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kCellID forIndexPath:indexPath];
    cell.model = self.dataArray[indexPath.row];
    
    return cell;
    
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    
    return CGSizeMake(self.itemWidth, self.height - 70);
}



@end
